package com.example.design.bilibili.singleton;

import javax.print.DocFlavor;

/**
 * 懒汉式-线程安全-同步方法
 */
public class SingletonTest4 {

    public static void main(String[] args) {

    }
}

class Singleton4{

    private static Singleton4 instance = null;

    private Singleton4(){

    }

    public synchronized static Singleton4 getInstance(){
        if(instance == null){
            instance = new Singleton4();
        }

        return instance;
    }
}